﻿using System;
using System.Collections.Generic;
using Sustainalytics.Entities;

namespace Sustainalytics.ClientDW.Entities
{


 

    public class CompanyHistoricalPerformance : IEntity // CompanyHistoryDataShort
    {
        public Guid Id { get; set; }

        public List<CompanyHistoryData> Last36Months { get; set; }
       
    }

    public class CompanyHistoryData : ICompanyRelatedEntity
    {

        public DateTime Date { get; set; }
        public Guid CompanyId { get; set; }
        public double OverallScore { get; set; }
        public double GovernanceScore { get; set; }
        public double SocialScore { get; set; }
        public double EnvironmentScore { get; set; }
        public float OverallAverage { get; set; }
        public float GovernanceAverage { get; set; }
        public float SocialAverage { get; set; }
        public float EnvironmentAverage { get; set; }
        public float OverallBestInClass { get; set; }
        public float GovernanceBestInClass { get; set; }
        public float SocialBestInClass { get; set; }
        public float EnvironmentBestInClass { get; set; }

        public static CompanyHistoryData Default
        {
            get
            {
                return new CompanyHistoryData
                {

                    EnvironmentAverage = -1,
                    EnvironmentBestInClass = -1,
                    EnvironmentScore = -1,
                    SocialAverage = -1,
                    SocialBestInClass = -1,
                    SocialScore = -1,
                    GovernanceAverage = -1,
                    GovernanceBestInClass = -1,
                    GovernanceScore = -1,
                    OverallBestInClass = -1,
                    OverallAverage = -1,
                    OverallScore = -1,
                };

            }
        }
        public static CompanyHistoryData InitDefault(Guid companyId,DateTime date)
        {
           
                return new CompanyHistoryData
                {
                    CompanyId = companyId,
                    Date = date,
                    EnvironmentAverage = -1,
                    EnvironmentBestInClass = -1,
                    EnvironmentScore = -1,
                    SocialAverage = -1,
                    SocialBestInClass = -1,
                    SocialScore = -1,
                    GovernanceAverage = -1,
                    GovernanceBestInClass = -1,
                    GovernanceScore = -1,
                    OverallBestInClass = -1,
                    OverallAverage = -1,
                    OverallScore = -1,
                };

            
        }

        private bool Equals(CompanyHistoryData other)
        {
            return  CompanyId.Equals(other.CompanyId) && OverallScore.Equals(other.OverallScore) && GovernanceScore.Equals(other.GovernanceScore) && SocialScore.Equals(other.SocialScore) && EnvironmentScore.Equals(other.EnvironmentScore) && OverallAverage.Equals(other.OverallAverage) && GovernanceAverage.Equals(other.GovernanceAverage) && SocialAverage.Equals(other.SocialAverage) && EnvironmentAverage.Equals(other.EnvironmentAverage) && OverallBestInClass.Equals(other.OverallBestInClass) && GovernanceBestInClass.Equals(other.GovernanceBestInClass) && SocialBestInClass.Equals(other.SocialBestInClass) && EnvironmentBestInClass.Equals(other.EnvironmentBestInClass);
        }

        public override bool Equals(object obj)
        {
            if (ReferenceEquals(null, obj))
            {
                return false;
            }
            if (ReferenceEquals(this, obj))
            {
                return true;
            }
            if (obj.GetType() != this.GetType())
            {
                return false;
            }
            return Equals((CompanyHistoryData) obj);
        }

        public override int GetHashCode()
        {
            unchecked
            {
                int hashCode = CompanyId.GetHashCode();
                hashCode = (hashCode*397) ^ OverallScore.GetHashCode();
                hashCode = (hashCode*397) ^ GovernanceScore.GetHashCode();
                hashCode = (hashCode*397) ^ SocialScore.GetHashCode();
                hashCode = (hashCode*397) ^ EnvironmentScore.GetHashCode();
                hashCode = (hashCode*397) ^ OverallAverage.GetHashCode();
                hashCode = (hashCode*397) ^ GovernanceAverage.GetHashCode();
                hashCode = (hashCode*397) ^ SocialAverage.GetHashCode();
                hashCode = (hashCode*397) ^ EnvironmentAverage.GetHashCode();
                hashCode = (hashCode*397) ^ OverallBestInClass.GetHashCode();
                hashCode = (hashCode*397) ^ GovernanceBestInClass.GetHashCode();
                hashCode = (hashCode*397) ^ SocialBestInClass.GetHashCode();
                hashCode = (hashCode*397) ^ EnvironmentBestInClass.GetHashCode();
                return hashCode;
            }
        }
    }
}
